package com.ea.eadp.nexus.test.workflow.newconsole.parentemail;

import com.ea.eadp.nexus.test.pageDefinition.newconsole.InputParentEmailPage;
import com.ea.eadp.nexus.test.workflow.WorkflowElement;
import com.ea.eadp.nexus.test.workflow.WorkflowElementArgument;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;

/**
 * Created with IntelliJ IDEA.
 * User: yjtao
 * Date: 12/23/14
 * Time: 3:42 PM
 * To change this template use File | Settings | File Templates.
 */
public class InputParentEmailWorkflowElement extends WorkflowElement {
    protected InputParentEmailPage page;

    public InputParentEmailWorkflowElement(
            WebDriver driver, WorkflowElementArgument argument
    ) {
        super(driver, argument);
        page = new InputParentEmailPage(driver);
    }

    @Override
    public void init() {
        page.waitPageLoadCompleted();
    }

    @Override
    public void doPreVerification() {
        Assert.assertEquals(
            page.getElementString(InputParentEmailPage.txt_inputEmailTitle),
            "No Parent/Guardian Email (Required)",
            "input email page wrong"
        );
    }

    @Override
    public void doAction() {
        page.sendControllerKey('A');
        log.info("Enter Origin Id:" + args.originId);
        page.enterEmailAddress(args.email);
        page.clickBlank("//div[@id='panel-parent-email-update']//span[@class='title']");
    }

    @Override
    public void moveNext() {
        page.sendControllerKey('A');
    }
}
